<?php
/**
 * @Author: Marte
 * @Date:   2017-08-19 21:41:42
 * @Last Modified by:   Marte
 * @Last Modified time: 2017-08-21 17:38:51
 */
session_start();
header('Content-Type:text/html;charset=utf-8');
if(isset($_GET['type']))
{
    $type=$_GET['type'];
}else{
    $type=1;
}
require '../data/config_connect.php';
// 分页效果

if(isset($_GET['page']))
{
  $_page=$_GET['page'];
  if(empty($_page)||$_page<=0||!is_numeric($_page))
  {
     $_page=1;
  }
  else
  {
    $_page=intval($_page);//取整
  }
}
else
{
  $_page=1;
}
// 公告分页效果
$_pagesize=15;//每页有几条
$_pagenum=($_page-1)*$_pagesize;//每页第一个
mysqli_query($_mysql,"SELECT noticeid FROM notice where status='1'");
// echo;
$_pagesnum=ceil(mysqli_affected_rows($_mysql)/$_pagesize);//共有几页
//如果$_page>总页数
if($_page>$_pagesnum)
{
  $_page=$_pagesnum;
}
// 公告面板
$_sql2='select * from notice where status="1" order by noticeid desc limit '.$_pagenum.','.$_pagesize.'';
$_result2=$_mysql->query($_sql2);
// 公告删除功能
if(isset($_GET['delid']))
{
    $delid=$_GET['delid'];
    $_sql='update notice set status="0" where noticeid='.$delid.'';
    $_result=$_mysql->query($_sql);
    if($_result)
    {
        echo "<script>alert('删除成功');location='admin_index.php?type=2'</script>";
    }
    else {
        echo "err".$_mysql->error;
    }
}

// 分页效果

if(isset($_GET['page1']))
{
  $_page1=$_GET['page1'];
  if(empty($_page1)||$_page1<=0||!is_numeric($_page1))
  {
     $_page1=1;
  }
  else
  {
    $_page1=intval($_page1);//取整
  }
}
else
{
  $_page1=1;
}
// 公告分页效果
$_pagesize1=9;//每页有几条
$_pagenum1=($_page1-1)*$_pagesize1;//每页第一个
mysqli_query($_mysql,"SELECT id FROM userregisters where status='1'");
// echo;
$_pagesnum1=ceil(mysqli_affected_rows($_mysql)/$_pagesize1);//共有几页
//如果$_page>总页数
if($_page1>$_pagesnum1)
{
  $_page1=$_pagesnum1;
}


// 用户面板
$_sql3='select id,issign,headicon,nickname,rank,regtime,isvip from userregisters where status="1" order by id desc limit '.$_pagenum1.',9';
$_result3=$_mysql->query($_sql3);

//添加黑名单
if(isset($_GET['delh']))
{
    $delh=$_GET['delh'];
    $_sql='update userregisters set status="0" where id='.$delh.'';
    $_result=$_mysql->query($_sql);
    if($_result)
    {
        echo "<script>alert('加入成功');location='admin_index.php?type=4'</script>";
    }
    else {
        echo "err".$_mysql->error;
    }
}
//标记
if(isset($_GET['sign']))
{
    $sign=$_GET['sign'];
    $_sql='update userregisters set issign="1" where id='.$sign.'';
    $_result=$_mysql->query($_sql);
    if($_result)
    {
        echo "<script>alert('标记成功');location='admin_index.php?type=4'</script>";
    }
    else {
        echo "err".$_mysql->error;
    }
}
// 详情
if(isset($_GET['id']))
{
    $_sqll2='select * from userregisters where id="'.$_GET['id'].'" ';
    $_resultt2=$_mysql->query($_sqll2);
    $_assoc4=$_resultt2->fetch_assoc();
}else
{

}
// 小说分页
if(isset($_GET['page2']))
{
  $_page2=$_GET['page2'];
  if(empty($_page2)||$_page2<=0||!is_numeric($_page2))
  {
     $_page2=1;
  }
  else
  {
    $_page2=intval($_page2);//取整
  }
}
else
{
  $_page2=1;
}
// 公告分页效果
$_pagesize2=13;//每页有几条
$_pagenum2=($_page2-1)*$_pagesize2;//每页第一个
mysqli_query($_mysql,"SELECT bookid FROM books where isshow='1'");
// echo;
$_num1=mysqli_affected_rows($_mysql);
$_pagesnum2=ceil(mysqli_affected_rows($_mysql)/$_pagesize2);//共有几页
//如果$_page>总页数
if($_page2>$_pagesnum2)
{
  $_page2=$_pagesnum2;
}
// 小说面板
$_sqll3='select * from books where isshow="1" order by bookid desc limit '.$_pagenum2.','.$_pagesize2.'';
$_resultt3=$_mysql->query($_sqll3);

// 作家分页
if(isset($_GET['page3']))
{
  $_page3=$_GET['page3'];
  if(empty($_page3)||$_page3<=0||!is_numeric($_page3))
  {
     $_page3=1;
  }
  else
  {
    $_page3=intval($_page3);//取整
  }
}
else
{
  $_page3=1;
}
// 公告分页效果
$_pagesize3=13;//每页有几条
$_pagenum3=($_page2-1)*$_pagesize3;//每页第一个
mysqli_query($_mysql,"SELECT id FROM author where status='1'");
// echo;
$_num=mysqli_affected_rows($_mysql);
$_pagesnum3=ceil(mysqli_affected_rows($_mysql)/$_pagesize3);//共有几页
//如果$_page>总页数
if($_page3>$_pagesnum3)
{
  $_page3=$_pagesnum3;
}
//作家面板
$_sqll4='select * from author where status="1" order by id desc limit '.$_pagenum3.','.$_pagesize3.'';
$_resultt4=$_mysql->query($_sqll4);

//标记作者
if(isset($_GET['delete']))
{
  $_ids=$_GET['id'];
  $_sql='update author set status="0" where id='.$_ids.'';
    $_result=$_mysql->query($_sql);
    if($_result)
    {
        echo "<script>alert('标记成功');location='admin_index.php?type=5'</script>";
    }
    else {
        echo "err".$_mysql->error;
    }
}
//小说下架
if(isset($_GET['delete1']))
{
  $_ids=$_GET['id'];
  $_sql='update books set isshow="0" where bookid='.$_ids.'';
    $_result=$_mysql->query($_sql);
    if($_result)
    {
        echo "<script>alert('下架成功');location='admin_index.php?type=3'</script>";
    }
    else {
        echo "err".$_mysql->error;
    }
}
//升级为VIP
if(isset($_GET['top']))
{
  $_ids=$_GET['id'];
  $_sql='update books set isvip="1" where bookid='.$_ids.'';
    $_result=$_mysql->query($_sql);
    if($_result)
    {
        echo "<script>alert('升级成功');location='admin_index.php?type=3'</script>";
    }
    else {
        echo "err".$_mysql->error;
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>墨悦轩后台管理中心</title>
    <link rel="stylesheet" type="text/css" href="../css/admin_index.css">
    <script src="../js/jquery-1.4.2.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/admin.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
    <div class="header">
        <div class="header_main">
                <i><img src="../images/logo3.png" alt=""></i>
                <span class="title">墨悦轩后台管理中心</span>
                <ul>
                <?php
                    if(isset($_SESSION['username']))
                    {
                        echo '<li><a href="" title=""><img src="../images/email.png" alt=""></a></li>
                    <li><a href="#" title="">'.$_SESSION['username'].'</a></li>
                    <li><a href="../data/user/logout.php?exit=1" title="">退出</a></li>
                    <li><a href="../index.php" title="">返回首页</a></li>';
                    }
                    else{
                        exit ;
                    }
                ?>

                </ul>
        </div>
    </div>
    <!-- 主体 -->
    <div class="main">
        <div class="main_left">
            <span class="title1">功能菜单</span>
            <ul>
                <li class="first"><a href="admin_index.php?type=1" title=""><img src="../images/admin-1.png" alt="">后台主页</a></li>
                <li class="xt "><a class="yes" href="admin_index.php?type=1" title=""><img src="../images/admin-2.png" alt="">系统信息管理</a></li>
                <li class="notice"><a href="admin_index.php?type=2" title=""><img src="../images/admin-3.png" alt="">公告管理</a></li>
                <li class="xs"><a href="admin_index.php?type=3" title=""><img src="../images/admin-4.png" alt="">小说管理</a></li>
                <li class="yh"><a href="admin_index.php?type=4" title=""><img src="../images/admin-5.png" alt="">用户管理</a></li>
                <li class="zj"><a href="admin_index.php?type=5" title=""><img src="../images/admin-7.png" alt="">作者管理</a></li>
                <li class="vip"><a href="admin_index.php?type=6" title=""><img src="../images/admin-8.png" alt="">VIP用户管理</a></li>

            </ul>
        </div>
        <div class="main_right">
            <?php
                    switch ($type) {
                        case '2':
                            include 'admin_index_notice.inc.php';
                            break;
                        case '7':
                            include 'admin_index_notice_send.inc.php';break;
                       case '4':
                       include 'admin_index_users.inc.php';break;
                       case '8':
                       include 'admin_index_userinfo.inc.php';break;
                       case '3':
                       include 'admin_novel_inc.php';break;
                       case '1':
                       include 'admin_system.inc.php';break;
                       case '5':
                       include 'admin_authors.inc.php';break;

                    }
            ?>
        </div>
    </div>
    <div class="clear">

    </div>
    <?php
        include '../include/zhuce.footer.inc.php';
        ?>
</body>
</html>
